<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <style>
        div {
            background-color: pink;
        }
    </style>
</head>
<body>
    <button id="btn">+1</button>
    <div>
        结果：
        <h3 id="display"></h3>
    </div>
</body>
<script type="text/javascript">
    $(function () {
        function add() {
            var counter = 0;
            return function plus() {
                counter++;
                return counter;
            }
        }

        let ad = add();

        $("#btn").click(function () {
            $("#display").text(ad());
            return false;
        });
    });
</script>
</html>